home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / STRINGS.SWG / 0001_Convert ASCIIZ to Turbo.pas next >
Pascal/Delphi Source File  |  1993-05-28  |  595b  |  14 lines

  1. Function Asc2Str(Var s; Max : Byte): String;
  2. { Converts an ASCIIZ String to a Turbo Pascal String }
  3. { With a maximum length of max.                      }
  4. Var
  5.   StArray  : Array[1..255] of Char Absolute s;
  6.   Len      : Integer;
  7. begin
  8.   Len        := Pos(#0,StArray)-1;                       { Get the length }
  9.   if (Len > Max) or (Len < 0) then               { length exceeds maximum }
  10.     Len      := Max;                                  { so set to maximum }
  11.   Asc2Str    := StArray;
  12.   Asc2Str[0] := Chr(Len);                                    { Set length }
  13. end;  { Asc2Str }
  14.